<?php
/* @var $this NewsCategoryController */
/* @var $model NewsCategory */

$this->breadcrumbs=array(
	'News Categories'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List NewsCategory', 'url'=>array('index')),
	array('label'=>'Create NewsCategory', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('news-category-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage News Categories</h1>

<?php $this->widget('bootstrap.widgets.BootGridView', array(
	'id'=>'news-category-grid',
	'dataProvider'=>$model->getChildren(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'url_key',
		'name',
		'index',
		#'parent_id',

		array(
			'class'=>'bootstrap.widgets.BootButtonColumn',
			'htmlOptions'=>array(
            	'style'=>'width:100px;;text-align:right;',
			),
			'buttons'=>array(
					'up'=>array(
					'label'=>'Move Up',
					'icon'=>'icon-arrow-up',
					'url'=>'"#".$data->id',
					'htmlOptions'=>array(
						'entryId'=>'',


					),
					'options'	=>	array(
						'class'	=>	'ajax',
					),
					'click'=>'function(e) {
						e.preventDefault();
						var id = $(this).attr("href");
						id = id.substr(1);
						$.post("'.$this->createUrl('moveUp').'", {id:id}, function(data, txtStatus) {
						$.fn.yiiGridView.update("children-entries-grid");
					});
					return false;
					}',
				),
			'down'=>array(
			'label'=>'Move Down',
					'icon'=>'icon-arrow-down',
					'url'=>'"#".$data->id',
					'options'	=>	array(
						'class'	=>	'ajax',
					),
					'htmlOptions'=>array(
					'entryId'=>'',
			),
			'click'=>'function(e) {
						e.preventDefault();
						var id = $(this).attr("href");
						id = id.substr(1);
						$.post("'.$this->createUrl('moveDown').'", {id:id}, function(data, txtStatus) {
						$.fn.yiiGridView.update("children-entries-grid");
					});
			return false;
			}',
			),
			),

			'template'=>'{up}{down}|{view}{update}{delete}',
		),
	),
)); ?>


<script language="JavaScript">
<!--
	jQuery(function($) {
	jQuery('#news-category-grid a.ajax').live('click',function() {

	var th=this;
	console.log('aaaa');
	$.fn.yiiGridView.update('news-category-grid', {
		type:'POST',
		url:$(this).attr('href'),
		success:function(data) {
//			ActMsg.showMessage(data);
			$.fn.yiiGridView.update('news-category-grid');
		},
	});
	return false;
})});
//-->
</script>